import { UserProfilesApi } from "../../request/api"
export default {
    namespaced: true,
    state: {
        // 购物车数量
        cartTotal: 0,
        // 用户信息
        userInfo: {
            headImg: require("../../assets/img/userImg.f8bbec5e.png"),
            nickName: "--",
            coin: "--"
        }
    },
    mutations: {
        updaeUserInfo(state, payload) {
            state.cartTotal = payload.cartTotal;
            state.userInfo = payload.userInfo
        },
        initUserInfo(state) {
            state.cartTotal = 0;
            // 用户信息
            state.userInfo = {
                headImg: require("../../assets/img/userImg.f8bbec5e.png"),
                nickName: "--",
                coin: "--"
            }
        }
    },
    actions: {
        asyncUpdaeUserInfo(context) {
            UserProfilesApi().then(res => {
                // console.log(res);
                context.commit("updaeUserInfo", res.data)
            })
        }
    },
}